import 'package:safetymonitor/app/core/core.dart';

/// 侧边栏类
class DrawerTitle {
  /// 标题展示
  static Widget title(String title, String icon, {bool isSelected = false}) {
    // 是否是svg图片
    final bool isSvg = icon.contains('.svg');
    return Column(
      children: [
        AppGaps.vGap20,
        Badge(
          backgroundColor: Colors.green,
          child: Stack(
            alignment: Alignment.center,
            children: [
              Container(
                width: 36.1.w,
                height: 36.w,
                margin: EdgeInsets.only(top: 3.w),
                decoration: BoxDecoration(
                  color: isSelected ? const Color(0xFF5C6DFF) : Colors.transparent,
                  borderRadius: BorderRadius.circular(10.r),
                ),
              ),
              Container(
                width: 36.w,
                height: 36.w,
                padding: EdgeInsets.all(8.w),
                decoration: BoxDecoration(
                  color: const Color(0xffEEF0FF),
                  borderRadius: BorderRadius.circular(10.r),
                ),
                child: isSvg
                    ? SvgPicture.asset(
                        icon,
                        colorFilter: isSelected
                            ? const ColorFilter.mode(Color(0xFF5C6DFF), BlendMode.srcIn)
                            : const ColorFilter.mode(Color(0xFFA0A7B5), BlendMode.srcIn),
                      )
                    : Image.asset(icon, color: isSelected ? null : const Color(0xFFA0A7B5)),
              ),
            ],
          ),
        ),
        AppGaps.vGap4,
        Text(
          title,
          textAlign: TextAlign.center,
          style: TextStyle(
            color: const Color(0xFFA0A7B5),
            fontSize: 12.sp,
            fontWeight: FontWeight.w500,
          ),
        ),
      ],
    );
  }

  /// 左边的标题展示
  static Widget titleDrawer(String title, String icon, {bool isSelected = false}) {
    // 是否是svg图片
    final bool isSvg = icon.contains('.svg');
    return Stack(
      alignment: Alignment.center,
      children: [
        Container(
          width: 180.w,
          height: 36.1.w,
          margin: EdgeInsets.only(top: 20.w),
          decoration: BoxDecoration(
            color: isSelected ? const Color(0xFF5C6DFF) : Colors.transparent,
            borderRadius: BorderRadius.circular(10.r),
          ),
        ),
        Container(
          width: 180.w,
          height: 36.w,
          padding: EdgeInsets.all(6.w),
          margin: EdgeInsets.only(top: 20.w, left: 3.w),
          decoration: BoxDecoration(
            color: const Color(0xffEEF0FF),
            borderRadius: BorderRadius.circular(10.r),
          ),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                title,
                style: TextStyle(
                  color: const Color(0xFFA0A7B5),
                  fontSize: 12.sp,
                  fontWeight: FontWeight.w500,
                ),
              ),
              Container(
                width: 20.w,
                height: 20.w,
                alignment: Alignment.center,
                child: isSvg
                    ? SvgPicture.asset(
                        icon,
                        colorFilter: isSelected
                            ? const ColorFilter.mode(Color(0xFF5C6DFF), BlendMode.srcIn)
                            : const ColorFilter.mode(Color(0xFFA0A7B5), BlendMode.srcIn),
                      )
                    : Image.asset(icon,
                        color: isSelected ? const Color(0xFF5C6DFF) : const Color(0xFFA0A7B5)),
              ),
            ],
          ),
        )
      ],
    );
  }
}
